package com.poorstu.web;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

import com.common.base.web.BaseAction;
import com.poorstu.manager.AdminMeg;
import com.poorstu.manager.LeaseManager;
import com.poorstu.model.LeaseMod;

public class LeaseChangeAction extends BaseAction {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
			
		try{
			//int alluserid=(Integer)request.getSession().getAttribute("alluserid");
		//	int allUserId=1;
			
		    DynaActionForm dyna=(DynaActionForm)form;
		    
			int leaseId=(Integer)dyna.get("leaseid");
			String leaseName=(String)dyna.get("leasename");
			String leaseContent=(String)dyna.get("leasecontent");
			
			LeaseMod leaseMod=new LeaseMod();
		    leaseMod.setLeaseId(leaseId);
			leaseMod.setLeaseName(leaseName);
			leaseMod.setLeaContent(leaseContent);
			leaseMod.setLeaTime(new Date());
			
			LeaseManager leaseMag=(LeaseManager)getBean("leaseManager");
			
			int a=leaseMag.leaseChange(leaseMod);
			if(a==1){
				return mapping.findForward("succ");
			}
		}catch(Exception e){
			e.printStackTrace();
			return mapping.findForward("failure");
			
		}
			return mapping.findForward("failure");
		
		
	}
	

}
